<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="div1" class="class-div1">
        <p id="p1" data-name="p1-data-name">this is p1</p>
        <p id="p2">this is p2</p>
    </div>
    <div id="div2">
        <p id="p3">this is p3</p>
        <p id="p4">this is p4</p>
    </div>
    <script type="text/javascript">
    // 新增节点
        var div = document.getElementById('div1')
        // 添加新节点
        var p1 = document.createElement('p')
        p1.innerHTML = 'this is p1'
        // 添加新创建的元素
        div1.appendChild(p1)
        // 移动已有的节点
        var p2 = document.getElementById('p2')
        div1.appendChild(p2)
    // 获取父元素和子元素
        var div1 = document.getElementById('div1')
        var parent = div1.parentElement
 
        var child = div1.childNodes
        div1.removeChild(child[0]) //删除节点
    </script>
</body>
</html>